import pygame
from pygame.locals import *



#follows the singleton pattern
#so if you need to use it just instantiate it
#it will always be connected to the same original instance
class Graphics:
    __slots__=("screen", "darkcolor", "lightcolor", "actioncolor")
    _instance = None
    
    def __new__(cls, *args, **kwargs):
        if not cls._instance:
            cls._instance = super(Graphics, cls).__new__(cls, *args, **kwargs)
        return cls._instance
    
    def __init__(self):
        print("init Graphics")
        
        darkcolor = (64, 64, 64)
        lightcolor = (160, 160, 160)
        actioncolor = (124, 255, 63)
        
        
        self.screen = pygame.display.set_mode((1200,800), DOUBLEBUF | HWSURFACE)
        pygame.display.set_caption("Tower")
        
        
        pygame.init() #init pygame
    
    def updatescreen(self):
        pygame.display.flip()
    
    #drawing primitives --------------------------
    #these handle the conversions from units to pixels
    #graphics deals with pixels internally and units
    #externally
    
    def rect(self, color, rect, width = 0):
        if color == 0:
            color == darkcolor
        elif color == 1:
            color == lightcolor
        else:
            color == actioncolor
            
        pygame.draw.rect(self.screen, color, rect, width)
    
    #end drawing primitives ----------------------
    
    def load(self):
        pass

    def cleanup(self):
        quit()
